Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

145
Views
Código JS para deshabilitar el desplazamiento y reemplazar con "desplazarse al siguiente div al deslizar hacia abajo, al div anterior al deslizar hacia arriba"

Estoy buscando una manera de poder reemplazar el método de desplazamiento predeterminado para dispositivos móviles de un sitio web.

Intenté implementar este código, pero se activa cada vez que hay un solo deslizamiento (que también contiene el desplazamiento a div y, por lo tanto, se activa una y otra vez).

¡Gracias por cualquier ayuda!

 var timer = null; window.addEventListener('scroll', function() { if(timer !== null) { clearTimeout(timer); } timer = setTimeout(function() { // do something }, 150); }, false); var lastScrollTop = 0; $(window).scroll(function(event){ var st = $(this).scrollTop(); if (st > lastScrollTop){ // downscroll code console.log('down') var $target = $(".archive-blog-posts-wrapper.active").prev(".archive-blog-posts-wrapper"); if ($target.length == 0) $target = $(".archive-blog-posts-wrapper:first"); $("html, body").animate( { scrollTop: $target.offset().top, }, "slow" ); $(".active").removeClass("active"); $target.addClass("active"); } else { // upscroll code console.log('up') var $target = $(".archive-blog-posts-wrapper.active").next(".archive-blog-posts-wrapper"); if ($target.length == 0) $target = $(".archive-blog-posts-wrapper:first"); $("html, body").animate( { scrollTop: $target.offset().top, }, "slow" ); $(".active").removeClass("active"); $target.addClass("active"); } lastScrollTop = st; });
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!